#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    connect(ui->pushButton, &QPushButton::clicked, this, &Widget::handleClicked);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handleClicked()
{
    this->setWindowTitle("修改窗口标题");
    qDebug() << "handleClicked()";
}

void Widget::handleClicked2()
{
    this->setWindowTitle("修改窗口标题2");
    qDebug() << "handleClicked2()";
}

void Widget::on_pushButton_2_clicked()
{
    // disconnect用的不多,最常见的情况是将一个信号重新进行绑定到另一个槽

    // 1. 断开原来的ui->pushButton 与槽的连接
    disconnect(ui->pushButton, &QPushButton::clicked, this, &Widget::handleClicked);
    // 2. 将 ui->pushButton 重新绑定到另一个槽
    connect(ui->pushButton, &QPushButton::clicked, this, &Widget::handleClicked2);
}

